package com.rockcent.mall.lib.repository;

import com.rockcent.mall.lib.domain.MarketMerchantCooperationRecord;
import com.rockcent.mall.lib.domain.enumclass.MarketMerchantCooperationStatus;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;

/**
 * Created by oyhk on 14-6-22.
 *
 * 商家申请
 */
@Repository
public interface MarketMerchantCooperationRecordRepository extends JpaRepository<MarketMerchantCooperationRecord, Long>, JpaSpecificationExecutor, MarketMerchantCooperationRecordRepositoryCustom {


    /**
     * 供应商 记录数
     * @param distributorMerchantId
     * @return
     */
    Long countByDistributorMerchantId(Long distributorMerchantId);

    /**
     * 分销商 记录数 区分不同状态
     * @param distributorMerchantId
     * @return
     */
    Long countBySupplierMerchantIdAndStatus(Long distributorMerchantId,MarketMerchantCooperationStatus status);


    /**
     * 供应商 记录
     * @param id
     * @param merchantId
     * @return
     */
    MarketMerchantCooperationRecord findByIdAndDistributorMerchantId(Long id, Long merchantId);

    /**
     * 分销商 记录
     * @param id
     * @param merchantId
     * @return
     */
    MarketMerchantCooperationRecord findByIdAndSupplierMerchantId(Long id, Long merchantId);

    /**
     * 对应分销商申请供应商记录
     * @param distributorMerchantId
     * @param supplierMerchantId
     * @param status 状态
     * @return
     */
    MarketMerchantCooperationRecord findByDistributorMerchantIdAndSupplierMerchantIdAndStatus(Long distributorMerchantId, Long supplierMerchantId, MarketMerchantCooperationStatus status);
}
